package com.tensquare.sms.listener;

import com.tensquare.sms.util.SmsUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * ------------------------------
 * 功能：
 * 作者：WF
 * 微信：hbxfwf13590332912
 * 创建时间：2021/9/8-15:57
 * ------------------------------
 */
@Component
@RabbitListener(queues = "sms")
public class SmsListener {
    @Autowired
    private SmsUtil smsUtil;
    @RabbitHandler
    public void getMessage(Map<String,String> map){
        System.out.println("接收到消息如下：" + map);
        //1. 得到取得的数据
        String phone = map.get("phone");
        String code = map.get("code");
        //2. 将消息发送给阿里大于
        smsUtil.sendSms(phone,code);

    }
}
